cmake_minimum_required(VERSION 3.13)
project(dmockdb VERSION 1.0 LANGUAGES C CXX)

# set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_BUILD_TYPE "Debug")
set(TEST_FLAG "Test")

set(CMAKE_CXX_FLAGS "-std=c++11 -lpthread ${CMAKE_CXX_FLAGS}")

if( CMAKE_BUILD_TYPE STREQUAL "Debug" )
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wno-unused-variable")
else( CMAKE_BUILD_TYPE STREQUAL "Release" )
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast")
endif( CMAKE_BUILD_TYPE STREQUAL "Debug" )

message("Build Type: ${CMAKE_BUILD_TYPE} ${CMAKE_CXX_FLAGS}")
message("Install prefix is: ${CMAKE_INSTALL_PREFIX}")

add_library(dmockdb SHARED "")
if (TEST_FLAG STREQUAL "Test")
    add_executable(dtest "")
    add_subdirectory(test)
endif (TEST_FLAG STREQUAL "Test")

# add_subdirectory(third-party/spdlog)
# add_subdirectory(third-party/crc32c)
add_subdirectory(include)
add_subdirectory(db)
add_subdirectory(util)

target_link_libraries(dmockdb
    spdlog
)

install(TARGETS dmockdb 
        LIBRARY DESTINATION lib)
install(DIRECTORY include/ 
        DESTINATION include/dmockdb
        FILES_MATCHING PATTERN "*.h*")